<?php


/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Gmap
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */
 
 
?>


<div class="headline" style="display: none">
  <h2>
    <?php echo $this->translate('Gmaps');?>
  </h2>
  <div class="tabs">
    <?php
      // Render the menu
      echo $this->navigation()
        ->menu()
        ->setContainer($this->navigation)
        ->render();
    ?>
  </div>
</div>

<div class='layout_right'>
  <div class='gmaps_gutter'>
  
    <div class='gmaps_gutter_owner'>
      <?php echo $this->htmlLink($this->owner->getHref(), $this->itemPhoto($this->owner, 'thumb.profile'), array('class'=>'gmaps_gutter_owner_photo')) ?>
      <div class='gmaps_gutter_owner_name'>
        <?php echo $this->htmlLink($this->owner->getHref(), $this->owner->getTitle(), array('class'=>'gmaps_gutter_name')); ?>      
      </div>
    </div> 
    
    <?php if (count($this->userCategories )):?>
      <h4><?php echo $this->translate('Categories');?></h4>
      <ul class="gmaps_gutter_categories">
          <li><?php echo $this->htmlLink(array(
              'route' => 'gmap_list',
              'user_id' => $this->owner->getIdentity(),
            ), $this->translate('All Categories'), array(
          )) ?></li>
          <?php foreach ($this->userCategories as $category): ?>
          <li><?php echo $this->htmlLink(array(
              'route' => 'gmap_list',
              'user_id' => $this->owner->getIdentity(),
              'category' => $category->category_id,
            ), $this->translate($category->category_name), array(
            'class' => $category->category_id == $this->category ? 'gmap_active_category' : ''
          )) ?></li>
          <?php endforeach; ?>
      </ul>
    <?php endif; ?>

    <?php if (count($this->userTags)): ?>
      <h4><?php echo $this->translate('Tags')?></h4>
      <ul class="gmaps_gutter_tags">
      <?php foreach ($this->userTags as $tag): ?>
        <li><?php echo $this->htmlLink(array(
              'route' => 'gmap_list',
              'user_id' => $this->owner->getIdentity(),
              'tag' => $tag->tag_id,
            ), "#" . $this->translate($tag->text), array(
            'class' => $tag->tag_id == $this->tag ? 'gmap_active_tag' : ''
          )) ?></li>
      <?php endforeach; ?>
      </ul>
    <?php endif; ?>

  </div>
  <!-- /gmaps_gutter -->
  
</div>
<!-- /layout_right -->

<div class='layout_middle'>
	<h2 class="gmap_header_title">
	  <?php echo $this->translate('%1$s\'s Gmap', $this->htmlLink($this->owner->getHref(), $this->owner->getTitle()))?>
  </h2>
  
  <?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
  
	  <div class="gmap_map_container_wrapper">
		  <?php $this->google_map->setHeight('500px')
		    ->setWidth('740px'); 
		  ?>
		  <?php echo $this->gmapMarkers($this->google_map, $this->paginator); ?>
	  </div>
	  
	  <div class="gmaps_results">
      <h3 class="sep"><span><?php echo $this->translate(array('%s location found','%s locations found', $this->paginator->getTotalItemCount()), $this->paginator->getTotalItemCount()); ?></span></h3>
	
      <ul class="gmaps_browse">
        <?php foreach( $this->paginator as $item ): ?>
          <li>
            <?php echo $this->htmlLink($item->getHref(), $this->itemPhoto($item, 'thumb.normal')) ?>
            <div class="gmap_info">
              <div class="gmap_title"><?php echo $this->htmlLink($item->getHref(), $item->getTitle()) ?>
                <?php if( $item->featured ): ?>
                  <img src='application/modules/Gmap/externals/images/featured.png' class='gmap_title_icon_featured' />
                <?php endif;?>
                <?php if( $item->sponsored ): ?>
                  <img src='application/modules/Gmap/externals/images/sponsored.png' class='gmap_title_icon_sponsored' />
                <?php endif;?>
              </div>
              <div class="gmap_address">
                <a href="javascript:void(0)" onclick="<?php echo $this->google_map->getOpenMarkerInfoWindowEventJs($item->getMapMarker(),$item->getMapInfoWindow())?>"><?php echo $item->formatted_address; ?></a>
              </div>
              <span class="gmap_stats">
                <?php echo $this->translate(array("%s view", "%s views", $item->view_count), $item->view_count); ?>
                - <?php echo $this->translate(array("%s comment", "%s comments", $item->comment_count), $item->comment_count); ?>
              </span>
              <span class="gmap_date"><?php echo $this->timestamp(strtotime($item->creation_date)) ?></span>
            </div>
          </li>
        <?php endforeach; ?>
      </ul>  
  
	  </div>
    <!-- /gmaps_results -->
    <?php echo $this->paginationControl($this->paginator); ?>       
    
  <?php else: ?>
    <div class="tip">
      <span>
        <?php echo $this->translate('Could not find any locations.');?>
        <?php if ($this->can_create): ?>
          <?php echo $this->translate('Get started by <a href=\'%s\'>post</a> one!', $this->url(array(), 'gmap_create')); ?>
        <?php endif; ?>
      </span>
    </div>
  <?php endif; ?>
  
</div>
<!-- /layout_middle -->

